/*****************************************************
*                                                                          
*               COPYRIGHT (c) 2015-2017 Broadlink Corporation              
*                         All Rights Reserved                              
*                                                                          
* The source code contained or described herein and all documents          
* related to the source code ("Material") are owned by Broadlink         
* Corporation or its licensors.  Title to the Material remains             
* with Broadlink Corporation or its suppliers and licensors.               
*                                                                          
* The Material is protected by worldwide copyright and trade secret        
* laws and treaty provisions. No part of the Material may be used,         
* copied, reproduced, modified, published, uploaded, posted, transmitted,  
* distributed, or disclosed in any way except in accordance with the       
* applicable license agreement.                                            
*                                                                          
* No license under any patent, copyright, trade secret or other            
* intellectual property right is granted to or conferred upon you by       
* disclosure or delivery of the Materials, either expressly, by            
* implication, inducement, estoppel, except in accordance with the         
* applicable license agreement.                                            
*                                                                          
* Unless otherwise agreed by Broadlink in writing, you may not remove or   
* alter this notice or any other notice embedded in Materials by Broadlink 
* or Broadlink's suppliers or licensors in any way.                        
*                                                                          
** Author: 
** Date: 2017-12-15
*
*****************************************************/

#ifndef __DNA_I2CSOFT_H_
#define __DNA_I2CSOFT_H_

#ifdef __cplusplus
extern "C"{
#endif

/***** INCLUDES *************************************/

/***** TYPEDEFS *************************************/

typedef struct dna_i2csoft_conf_t
{
    int     sclkpin;
    int     sdiopin;
    int     freq;
} dna_i2csoft_conf_t;


typedef struct dna_i2csoft_data_t
{	
    unsigned int    slave_addr;
    unsigned char   *data;
    unsigned int    pkglen;
} dna_i2csoft_data_t;

/***** DEFINES **************************************/

enum
{
    DNA_I2CSOFT_STATUS_OK = 0,
    DNA_I2CSOFT_ERR_PARA,
    DNA_I2CSOFT_ERR_COMM,
    DNA_I2CSOFT_ERR_GPIO,
    DNA_I2CSOFT_ERR_FREQ,
    DNA_I2CSOFT_ERR_START,
    DNA_I2CSOFT_ERR_STOP,
    DNA_I2CSOFT_ERR_WRITE,
    DNA_I2CSOFT_ERR_READ,
    DNA_I2CSOFT_ERR_ACK,
    DNA_I2CSOFT_ERR_PULL_UP,
};

/***** CONSTANTS ************************************/

/***** VARIABLES ************************************/

/***** EXTERNAL VARIABLES ***************************/

/***** EXTERNAL FUNCTIONS ***************************/

/***** PROTOTYPES ***********************************/

int dna_i2c_soft_master_init(dna_i2csoft_conf_t *conf);
int dna_i2c_soft_master_deinit(void);
int dna_i2c_soft_master_block_write(dna_i2csoft_data_t *conf);
int dna_i2c_soft_master_block_read(dna_i2csoft_data_t *conf);
int dna_i2c_soft_write_without_slave(dna_i2csoft_data_t * conf);



#ifdef __cplusplus
}
#endif

#endif /* __DNA_I2CSOFT_H_ */

